{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 作业要求\n",
    "调用高德Web服务API文档中所有功能\n",
    "\n",
    "* 至少完成每一个模块中的一个子功能的API调用，封装成函数，开源到github/gitee上\n",
    "\n",
    "* 在调用每一个功能的同时，思考其背后是否含有ML、AI的功能（比如计算机视觉、语音识别、推荐算法等），并整理思考的结果，在调用API代码模块中用markdown说明。\n",
    "\n",
    "* 尝试设计一个简单的应用（不要求写代码），至少涉及3个API功能。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### ML(Machine Learning)\n",
    "机器学习是一门多领域交叉学科，涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科。专门研究计算机怎样模拟或实现人类的学习行为，以获取新的知识或技能，重新组织已有的知识结构使之不断改善自身的性能。它是人工智能的核心，是使计算机具有智能的根本途径。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### AI（Artificial Intelligence）\n",
    "人工智能它是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门新的技术科学。\n",
    "人工智能是计算机科学的一个分支，它企图了解智能的实质，并生产出一种新的能以人类智能相似的方式做出反应的智能机器，该领域的研究包括机器人、语言识别、图像识别、自然语言处理和专家系统等。人工智能从诞生以来，理论和技术日益成熟，应用领域也不断扩大，可以设想，未来人工智能带来的科技产品，将会是人类智慧的“容器”。人工智能可以对人的意识、思维的信息过程的模拟。人工智能不是人的智能，但能像人那样思考、也可能超过人的智能。\n",
    "人工智能是一门极富挑战性的科学，从事这项工作的人必须懂得计算机知识，心理学和哲学。人工智能是包括十分广泛的科学，它由不同的领域组成，如机器学习，计算机视觉等等，总的说来，人工智能研究的一个主要目标是使机器能够胜任一些通常需要人类智能才能完成的复杂工作。但不同的时代、不同的人对这种“复杂工作”的理解是不同的。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 获取地理编码"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 此部分可用于导航等基本推荐算法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import requests\n",
    "key ='0bb20430af3ae6336d0e9f0f21c10c1a'\n",
    "# 此部分可用于导航等基本推荐算法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "def geo(address:str,city=None)->dict:\n",
    "    \"\"\"获取地理编码\"\"\"\n",
    "    parameters={\n",
    "        'key': key,\n",
    "        'address':address,\n",
    "        'city':city,\n",
    "        'citylimit':True\n",
    "        }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/geocode/geo?parameters\", params=parameters)\n",
    "    data = r.json()['geocodes'][0]['location']\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "#l老师未曾封装的情况\n",
    "# 中大南方 = geocode('广东省广州市从化区中山大学南方学院')\n",
    "# 中大南方"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "#l老师未曾封装的情\n",
    "# 温泉政府 = geocode('广东省广州市从化区温泉镇政府')\n",
    "# 温泉政府"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.679287,23.632575'"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo(\"广东省广州市从化区中山大学南方学院\",\"广州\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.632401,23.616941'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo(\"广东省广州市从化区温泉镇政府\",\"广州\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.669129,23.600956'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo(\"广东省广州市从化区龙岗社区居委会\",\"广州\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 路径规划"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 推荐算法规划路线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "def walking(origin,destination,sig=None)->dict:\n",
    "    url = 'https://restapi.amap.com/v3/direction/walking?parameters'\n",
    "    params={\n",
    "        'key':key,\n",
    "        'origin':origin,\n",
    "        'destination':destination,\n",
    "        'output':'json'\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    data = response.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 不知道哪里有问题\n",
    "def walking(origin:str,destination:str)->dict:   \n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'origin':origin,\n",
    "        'destination':destination,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/direction/walking?parameters\", params=parameters)\n",
    "    data = r.json()['route']['paths'][0]['steps']\n",
    "    for i in range(0,len(data)):\n",
    "        print(data[int(i)]['instruction'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "向南步行161米右转\n",
      "向西步行99米左转\n",
      "向南步行237米左转\n",
      "向南步行498米向右前方行走\n",
      "沿源富街向西南步行1568米直行\n",
      "沿源湖街向西步行784米右转\n",
      "沿龙泉路向西北步行1723米向左前方行走\n",
      "沿龙泉路向西步行67米向左前方行走\n",
      "沿温泉大道向西步行22米右转\n",
      "步行13米左转\n",
      "沿温泉大道向西南步行1425米右转\n",
      "向西北步行96米右转\n",
      "向北步行66米到达目的地\n"
     ]
    }
   ],
   "source": [
    "walking(geo(\"广东省广州市从化区中山大学南方学院\",\"广州\"),geo(\"广东省广州市从化区温泉镇政府\",\"广州\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 行政区域查询"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 机器学习查询行政区划，直接输出结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 可加入下级行政区使用‘subdirtrict’后面标注数字\n",
    "def district(keywords:str)->dict:\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/config/district?parameters\", params=parameters)\n",
    "    data = r.json()['districts'][0]['districts']\n",
    "    print(\"----\"+keywords + \"有以下几个行政区域----\")\n",
    "    for i in data:\n",
    "        print(i['name'])\n",
    "    return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----广东有以下几个行政区域----\n",
      "肇庆市\n",
      "佛山市\n",
      "汕头市\n",
      "惠州市\n",
      "深圳市\n",
      "珠海市\n",
      "湛江市\n",
      "阳江市\n",
      "汕尾市\n",
      "潮州市\n",
      "江门市\n",
      "云浮市\n",
      "东沙群岛\n",
      "茂名市\n",
      "河源市\n",
      "梅州市\n",
      "东莞市\n",
      "揭阳市\n",
      "清远市\n",
      "韶关市\n",
      "广州市\n",
      "中山市\n"
     ]
    }
   ],
   "source": [
    "district('广东')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----江西有以下几个行政区域----\n",
      "新余市\n",
      "抚州市\n",
      "九江市\n",
      "鹰潭市\n",
      "赣州市\n",
      "南昌市\n",
      "宜春市\n",
      "吉安市\n",
      "景德镇市\n",
      "上饶市\n",
      "萍乡市\n"
     ]
    }
   ],
   "source": [
    "district('江西')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 搜素POI "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 可以用在推荐算法上，帮助人们选择附近的餐厅"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 可以用在推荐算法上，帮助人们选择附近的餐厅\n",
    "def poi(keywords:str,city:str)->dict:\n",
    "    parameters={\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'city':city,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/place/text?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    pois = []\n",
    "    pois.extend(data['pois'])\n",
    "    import pandas as pd\n",
    "    df_input = pd.DataFrame(pois)\n",
    "    return df_input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>parent</th>\n",
       "      <th>childtype</th>\n",
       "      <th>name</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>biz_type</th>\n",
       "      <th>address</th>\n",
       "      <th>location</th>\n",
       "      <th>tel</th>\n",
       "      <th>distance</th>\n",
       "      <th>biz_ext</th>\n",
       "      <th>pname</th>\n",
       "      <th>cityname</th>\n",
       "      <th>adname</th>\n",
       "      <th>importance</th>\n",
       "      <th>shopid</th>\n",
       "      <th>shopinfo</th>\n",
       "      <th>poiweight</th>\n",
       "      <th>photos</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>B0FFK712FX</td>\n",
       "      <td>B0FFF5RJ1U</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(凯华国际DP店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>冼村路5号104房近K11凯华国际中心</td>\n",
       "      <td>113.327219,23.117334</td>\n",
       "      <td>020-85208628</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>天河区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>B0FFK7127Y</td>\n",
       "      <td>B02F38PFKU</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(蛇口网谷GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>南海大道1057号科技大厦2期B栋103房</td>\n",
       "      <td>113.918523,22.494681</td>\n",
       "      <td>0755-26673095</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>B0FFK7122K</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>喜茶(园岭星光广场GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>红岭中路2061号园岭花园裙楼1楼1010号铺</td>\n",
       "      <td>114.104188,22.555112</td>\n",
       "      <td>0755-25129404</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.0', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>B0FFK711WJ</td>\n",
       "      <td>B0FFGDDLUB</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(盈峰中心GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>盈峰中心1层108室</td>\n",
       "      <td>113.939499,22.522579</td>\n",
       "      <td>0755-26904965</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '27.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>B0FFK711S0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>喜茶(丰盛町GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>车公庙丰盛町地下阳光街BCD区C1-089,C1-091,C1-093B</td>\n",
       "      <td>114.024776,22.535568</td>\n",
       "      <td>0755-82544156;13510507476</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>B0FFK711LW</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>喜茶(中科纳能GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>粤兴六道中科纳能大厦B座1层B02</td>\n",
       "      <td>113.941148,22.526739</td>\n",
       "      <td>0755-33315903</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>B0FFK711G1</td>\n",
       "      <td>B02F300988</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(紫荆城GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店|购物服务;购物相关场所;购物相关场所</td>\n",
       "      <td>050700|060000</td>\n",
       "      <td>diner</td>\n",
       "      <td>振兴路55号紫荆城商业广场1层A16号</td>\n",
       "      <td>114.088713,22.546379</td>\n",
       "      <td>0755-83258250</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '5.0', 'cost': '7.00', 'meal_orderi...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>B0FFK7117H</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>喜茶(海上世界店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>海滨花园商业中心1栋103铺海上世界A出口KFC旁</td>\n",
       "      <td>113.915632,22.484082</td>\n",
       "      <td>0755-21614591</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>B0FFK71106</td>\n",
       "      <td>B0FFFZRC7K</td>\n",
       "      <td>201</td>\n",
       "      <td>喜茶(深圳机场GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>宝安国际机场航站楼3S-08-01近23号登机口</td>\n",
       "      <td>113.811463,22.628429</td>\n",
       "      <td>0755-26659705</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '30.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>宝安区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>B0FFK710VQ</td>\n",
       "      <td>B0FFJ6C1YS</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(深圳湾GO店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>高新南九道10号深圳湾科技生态园3区10栋裙楼01层33-34号</td>\n",
       "      <td>113.951604,22.530259</td>\n",
       "      <td>0755-86966251</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>B0FFJFTOC0</td>\n",
       "      <td>B0FFG23ZZ1</td>\n",
       "      <td>201</td>\n",
       "      <td>喜茶(IGC天汇广场)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>珠江新城兴民路222号IGC天汇广场B1层B115</td>\n",
       "      <td>113.332961,23.116459</td>\n",
       "      <td>020-37392323</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>天河区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>B0FFJCSNWN</td>\n",
       "      <td>B0FFH0YOUV</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(讯美科技GO店)</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>050000</td>\n",
       "      <td>diner</td>\n",
       "      <td>粤海街道科苑路8号讯美科技广场3号楼大堂部分区域</td>\n",
       "      <td>113.945711,22.545916</td>\n",
       "      <td>0755-26929157</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>B0FFJ8YP49</td>\n",
       "      <td>B0FFH11N97</td>\n",
       "      <td>201</td>\n",
       "      <td>喜茶(富力海珠城热麦店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>江南西路1号富力海珠城A区1楼101B</td>\n",
       "      <td>113.273143,23.095547</td>\n",
       "      <td>020-85208698</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>海珠区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>B0FFJ7UKHX</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>HEYTEA(讯美科技店)</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>050000</td>\n",
       "      <td>diner</td>\n",
       "      <td>[]</td>\n",
       "      <td>113.945786,22.545666</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>B0FFJ4QTCW</td>\n",
       "      <td>B0FFHEJYQ3</td>\n",
       "      <td>201</td>\n",
       "      <td>喜茶(海雅缤纷广场南山店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>南海大道海雅缤纷城广场1楼1S49号</td>\n",
       "      <td>113.929479,22.518569</td>\n",
       "      <td>0755-26914953</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>南山区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>B0FFJ2K8GS</td>\n",
       "      <td>B0FFF05SW2</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(小榄海港城店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>小榄镇升平东路1号海港城1层</td>\n",
       "      <td>113.256635,22.673452</td>\n",
       "      <td>0760-22113800</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.0', 'cost': '26.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>中山市</td>\n",
       "      <td>中山市</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>B0FFJ1M4JL</td>\n",
       "      <td>B02F37UI67</td>\n",
       "      <td>302</td>\n",
       "      <td>HEYTEA喜茶(龙城万科里)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>中心城龙翔大道龙城万科里L1层49号</td>\n",
       "      <td>114.251029,22.716860</td>\n",
       "      <td>0755-28909053</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '28.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>龙岗区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>B0FFIZD8TX</td>\n",
       "      <td>B0FFJ16G8Q</td>\n",
       "      <td>202</td>\n",
       "      <td>喜茶(布吉万象汇店)</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>050000</td>\n",
       "      <td>diner</td>\n",
       "      <td>布吉街道翔鸽路2号布吉万象汇L1层L177号</td>\n",
       "      <td>114.131178,22.592368</td>\n",
       "      <td>0755-28918620</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>龙岗区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>B0FFIZ46UQ</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>喜茶(利和新地店)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>银通街2号利和公寓利和新地汇首层20卡之2</td>\n",
       "      <td>113.385060,22.511468</td>\n",
       "      <td>0760-88325552</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '26.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>中山市</td>\n",
       "      <td>中山市</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>B0FFIVFGNL</td>\n",
       "      <td>B0FFJ939YR</td>\n",
       "      <td>201</td>\n",
       "      <td>喜茶(天环广场东塔)</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>050700</td>\n",
       "      <td>diner</td>\n",
       "      <td>天河路218号天环广场东塔B2层B234-35</td>\n",
       "      <td>113.324995,23.132926</td>\n",
       "      <td>020-85201328</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.5', 'cost': '29.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>天河区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            id      parent childtype             name  \\\n",
       "0   B0FFK712FX  B0FFF5RJ1U       202      喜茶(凯华国际DP店)   \n",
       "1   B0FFK7127Y  B02F38PFKU       202      喜茶(蛇口网谷GO店)   \n",
       "2   B0FFK7122K          []        []    喜茶(园岭星光广场GO店)   \n",
       "3   B0FFK711WJ  B0FFGDDLUB       202      喜茶(盈峰中心GO店)   \n",
       "4   B0FFK711S0          []        []       喜茶(丰盛町GO店)   \n",
       "5   B0FFK711LW          []        []      喜茶(中科纳能GO店)   \n",
       "6   B0FFK711G1  B02F300988       202       喜茶(紫荆城GO店)   \n",
       "7   B0FFK7117H          []        []        喜茶(海上世界店)   \n",
       "8   B0FFK71106  B0FFFZRC7K       201      喜茶(深圳机场GO店)   \n",
       "9   B0FFK710VQ  B0FFJ6C1YS       202       喜茶(深圳湾GO店)   \n",
       "10  B0FFJFTOC0  B0FFG23ZZ1       201      喜茶(IGC天汇广场)   \n",
       "11  B0FFJCSNWN  B0FFH0YOUV       202      喜茶(讯美科技GO店)   \n",
       "12  B0FFJ8YP49  B0FFH11N97       201     喜茶(富力海珠城热麦店)   \n",
       "13  B0FFJ7UKHX          []        []    HEYTEA(讯美科技店)   \n",
       "14  B0FFJ4QTCW  B0FFHEJYQ3       201    喜茶(海雅缤纷广场南山店)   \n",
       "15  B0FFJ2K8GS  B0FFF05SW2       202       喜茶(小榄海港城店)   \n",
       "16  B0FFJ1M4JL  B02F37UI67       302  HEYTEA喜茶(龙城万科里)   \n",
       "17  B0FFIZD8TX  B0FFJ16G8Q       202       喜茶(布吉万象汇店)   \n",
       "18  B0FFIZ46UQ          []        []        喜茶(利和新地店)   \n",
       "19  B0FFIVFGNL  B0FFJ939YR       201       喜茶(天环广场东塔)   \n",
       "\n",
       "                               type       typecode biz_type  \\\n",
       "0                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "1                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "2                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "3                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "4                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "5                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "6   餐饮服务;冷饮店;冷饮店|购物服务;购物相关场所;购物相关场所  050700|060000    diner   \n",
       "7                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "8                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "9                      餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "10                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "11                 餐饮服务;餐饮相关场所;餐饮相关         050000    diner   \n",
       "12                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "13                 餐饮服务;餐饮相关场所;餐饮相关         050000    diner   \n",
       "14                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "15                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "16                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "17                 餐饮服务;餐饮相关场所;餐饮相关         050000    diner   \n",
       "18                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "19                     餐饮服务;冷饮店;冷饮店         050700    diner   \n",
       "\n",
       "                                 address              location  \\\n",
       "0                    冼村路5号104房近K11凯华国际中心  113.327219,23.117334   \n",
       "1                  南海大道1057号科技大厦2期B栋103房  113.918523,22.494681   \n",
       "2                红岭中路2061号园岭花园裙楼1楼1010号铺  114.104188,22.555112   \n",
       "3                             盈峰中心1层108室  113.939499,22.522579   \n",
       "4   车公庙丰盛町地下阳光街BCD区C1-089,C1-091,C1-093B  114.024776,22.535568   \n",
       "5                      粤兴六道中科纳能大厦B座1层B02  113.941148,22.526739   \n",
       "6                    振兴路55号紫荆城商业广场1层A16号  114.088713,22.546379   \n",
       "7              海滨花园商业中心1栋103铺海上世界A出口KFC旁  113.915632,22.484082   \n",
       "8               宝安国际机场航站楼3S-08-01近23号登机口  113.811463,22.628429   \n",
       "9       高新南九道10号深圳湾科技生态园3区10栋裙楼01层33-34号  113.951604,22.530259   \n",
       "10             珠江新城兴民路222号IGC天汇广场B1层B115  113.332961,23.116459   \n",
       "11              粤海街道科苑路8号讯美科技广场3号楼大堂部分区域  113.945711,22.545916   \n",
       "12                   江南西路1号富力海珠城A区1楼101B  113.273143,23.095547   \n",
       "13                                    []  113.945786,22.545666   \n",
       "14                    南海大道海雅缤纷城广场1楼1S49号  113.929479,22.518569   \n",
       "15                        小榄镇升平东路1号海港城1层  113.256635,22.673452   \n",
       "16                    中心城龙翔大道龙城万科里L1层49号  114.251029,22.716860   \n",
       "17                布吉街道翔鸽路2号布吉万象汇L1层L177号  114.131178,22.592368   \n",
       "18                 银通街2号利和公寓利和新地汇首层20卡之2  113.385060,22.511468   \n",
       "19               天河路218号天环广场东塔B2层B234-35  113.324995,23.132926   \n",
       "\n",
       "                          tel distance  \\\n",
       "0                020-85208628       []   \n",
       "1               0755-26673095       []   \n",
       "2               0755-25129404       []   \n",
       "3               0755-26904965       []   \n",
       "4   0755-82544156;13510507476       []   \n",
       "5               0755-33315903       []   \n",
       "6               0755-83258250       []   \n",
       "7               0755-21614591       []   \n",
       "8               0755-26659705       []   \n",
       "9               0755-86966251       []   \n",
       "10               020-37392323       []   \n",
       "11              0755-26929157       []   \n",
       "12               020-85208698       []   \n",
       "13                         []       []   \n",
       "14              0755-26914953       []   \n",
       "15              0760-22113800       []   \n",
       "16              0755-28909053       []   \n",
       "17              0755-28918620       []   \n",
       "18              0760-88325552       []   \n",
       "19               020-85201328       []   \n",
       "\n",
       "                                              biz_ext pname cityname adname  \\\n",
       "0   {'rating': '4.5', 'cost': '28.00', 'meal_order...   广东省      广州市    天河区   \n",
       "1   {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "2   {'rating': '4.0', 'cost': '28.00', 'meal_order...   广东省      深圳市    福田区   \n",
       "3   {'rating': '4.5', 'cost': '27.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "4   {'rating': '4.5', 'cost': '28.00', 'meal_order...   广东省      深圳市    福田区   \n",
       "5   {'rating': '4.5', 'cost': '28.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "6   {'rating': '5.0', 'cost': '7.00', 'meal_orderi...   广东省      深圳市    福田区   \n",
       "7   {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "8   {'rating': '4.5', 'cost': '30.00', 'meal_order...   广东省      深圳市    宝安区   \n",
       "9   {'rating': '4.5', 'cost': '28.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "10  {'rating': '4.5', 'cost': '28.00', 'meal_order...   广东省      广州市    天河区   \n",
       "11  {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "12  {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      广州市    海珠区   \n",
       "13   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      深圳市    南山区   \n",
       "14  {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      深圳市    南山区   \n",
       "15  {'rating': '4.0', 'cost': '26.00', 'meal_order...   广东省      中山市    中山市   \n",
       "16  {'rating': '4.5', 'cost': '28.00', 'meal_order...   广东省      深圳市    龙岗区   \n",
       "17  {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      深圳市    龙岗区   \n",
       "18  {'rating': '4.5', 'cost': '26.00', 'meal_order...   广东省      中山市    中山市   \n",
       "19  {'rating': '4.5', 'cost': '29.00', 'meal_order...   广东省      广州市    天河区   \n",
       "\n",
       "   importance shopid shopinfo poiweight  \\\n",
       "0          []     []        0        []   \n",
       "1          []     []        0        []   \n",
       "2          []     []        0        []   \n",
       "3          []     []        0        []   \n",
       "4          []     []        0        []   \n",
       "5          []     []        0        []   \n",
       "6          []     []        0        []   \n",
       "7          []     []        0        []   \n",
       "8          []     []        0        []   \n",
       "9          []     []        0        []   \n",
       "10         []     []        0        []   \n",
       "11         []     []        0        []   \n",
       "12         []     []        0        []   \n",
       "13         []     []        0        []   \n",
       "14         []     []        0        []   \n",
       "15         []     []        0        []   \n",
       "16         []     []        0        []   \n",
       "17         []     []        0        []   \n",
       "18         []     []        0        []   \n",
       "19         []     []        0        []   \n",
       "\n",
       "                                               photos  \n",
       "0   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "1   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "2   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "3   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "4   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "5   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "6   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "7   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "8   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "9   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "10  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "11  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "12  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "13                                                 []  \n",
       "14  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "15  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "16  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "17  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "18  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "19  [{'url': 'http://store.is.autonavi.com/showpic...  "
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = poi(\"喜茶\",\"广东\")\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## IP定位"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 人工智能方面直接上传至推荐算法，根据定位推送广告等"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ip(ip:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'ip':ip,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/ip?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    del data['status']\n",
    "    del data['info']\n",
    "    df = [\"省份：%s\"%(data['province']),\"地区：%s\"%(data['city']),\"地理编码：%s\"%(data['adcode']),\"经纬度： %s\"%(data['rectangle'])]\n",
    "    print(\"ip:\"+ip)\n",
    "    for i in df:\n",
    "        print(i)\n",
    "    return    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ip:182.254.192.28\n",
      "省份：广东省\n",
      "地区：广州市\n",
      "地理编码：440100\n",
      "经纬度： 113.1017375,22.93212254;113.6770499,23.3809537\n"
     ]
    }
   ],
   "source": [
    "ip(\"182.254.192.28\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 批量请求"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 机器学习方面可以批量处理请求"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'status': 200,\n",
       "  'body': {'suggestion': {'keywords': {}, 'cities': {}},\n",
       "   'info': 'OK',\n",
       "   'status': '1',\n",
       "   'count': '878',\n",
       "   'pois': [{'typecode': '080000',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFIT4V37',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.509300,39.261324',\n",
       "     'distance': '1935',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '昌丰路与昌盛街交叉口东150米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;体育休闲服务场所;体育休闲服务场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '利民老年公寓',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080500',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFM1WN4Q',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.473800,39.284305',\n",
       "     'distance': '2684',\n",
       "     'tel': '13102692203;15032998415',\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '永丰路与建设大街交叉口北行200米再东行200米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/02f9a9353f15bb7c882c281addaca79a',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/462da2324343c04c255e5b6b55403952',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/dfc87db906b2994dae80342d4563b1e9',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;休闲场所;休闲场所',\n",
       "     'shopinfo': '1',\n",
       "     'name': '唐山兵途枪战运动',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080301',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFF2T193',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.471098,39.281979',\n",
       "     'distance': '2861',\n",
       "     'tel': '0315-8037777',\n",
       "     'biz_ext': {'rating': '4.3', 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '建设大街与永丰路交叉口西南角',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/c8fd0a18befbe849ce8df7908d88ed24',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/468baaf5453e6c1b38d0c4c417183b40',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/a0a5fff0b63e60b3508c2ecb197d07e5',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;娱乐场所;夜总会',\n",
       "     'shopinfo': '0',\n",
       "     'name': '一代佳人夜总会',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080000',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFKPS8TZ',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.471344,39.273170',\n",
       "     'distance': '2864',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '垦丰大街与永丰路交叉口南50米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;体育休闲服务场所;体育休闲服务场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '新少年跆拳道馆',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080402',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B013B031EO',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.469256,39.278622',\n",
       "     'distance': '2989',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '曙光街23号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;度假疗养场所;疗养院',\n",
       "     'shopinfo': '0',\n",
       "     'name': '光荣院(曙光街)',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080500',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFHF91Y9',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.467429,39.273141',\n",
       "     'distance': '3196',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '垦丰大街8号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;休闲场所;休闲场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '曹妃甸区老干部活动中心',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080119',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFLDK6TP',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.466867,39.281969',\n",
       "     'distance': '3222',\n",
       "     'tel': '17736580504',\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '建设大街红赫世家东底商58号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/b59e23956de23e47401416a6b4808c0c',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;运动场馆;跆拳道场馆',\n",
       "     'shopinfo': '0',\n",
       "     'name': '泽仁跆拳道',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080000',\n",
       "     'adname': '滦南县',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFH9MB8R',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.527757,39.301926',\n",
       "     'distance': '3343',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '杨柏线北50米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;体育休闲服务场所;体育休闲服务场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '陶乐宝儿童乐园',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080304',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFLOR4DN',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.466494,39.287701',\n",
       "     'distance': '3395',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '青年城二期东底商24号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/29997dd7b0c66b1dc6f15a253918ccf2',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/098df33a76f03e8d55672683f63da5d8',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;娱乐场所;酒吧',\n",
       "     'shopinfo': '1',\n",
       "     'name': 'ELK酒吧',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080113',\n",
       "     'adname': '滦南县',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFMB6BAG',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.528670,39.302678',\n",
       "     'distance': '3457',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': {},\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;运动场馆;台球厅',\n",
       "     'shopinfo': '0',\n",
       "     'name': '下午时光台球俱乐部',\n",
       "     'childtype': {}}],\n",
       "   'infocode': '10000'},\n",
       "  'header': {'gsid': '011137149035158758280117300018601532358',\n",
       "   'Vary': 'Accept-Encoding',\n",
       "   'Content-Type': 'application/json;charset=UTF-8',\n",
       "   'Access-Control-Allow-Methods': '*',\n",
       "   'Access-Control-Allow-Origin': '*',\n",
       "   'sc': '0.114',\n",
       "   'Content-Length': 5564,\n",
       "   'Access-Control-Allow-Headers': 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,key,x-biz,x-info,platinfo,encr,enginever,gzipped,poiid',\n",
       "   'X-Powered-By': 'ring/1.0.0'}},\n",
       " {'status': 200,\n",
       "  'body': {'suggestion': {'keywords': {}, 'cities': {}},\n",
       "   'info': 'OK',\n",
       "   'status': '1',\n",
       "   'count': '878',\n",
       "   'pois': [{'typecode': '080000',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFIT4V37',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.509300,39.261324',\n",
       "     'distance': '1935',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '昌丰路与昌盛街交叉口东150米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;体育休闲服务场所;体育休闲服务场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '利民老年公寓',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080500',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFM1WN4Q',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.473800,39.284305',\n",
       "     'distance': '2684',\n",
       "     'tel': '13102692203;15032998415',\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '永丰路与建设大街交叉口北行200米再东行200米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/02f9a9353f15bb7c882c281addaca79a',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/462da2324343c04c255e5b6b55403952',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/dfc87db906b2994dae80342d4563b1e9',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;休闲场所;休闲场所',\n",
       "     'shopinfo': '1',\n",
       "     'name': '唐山兵途枪战运动',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080301',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFF2T193',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.471098,39.281979',\n",
       "     'distance': '2861',\n",
       "     'tel': '0315-8037777',\n",
       "     'biz_ext': {'rating': '4.3', 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '建设大街与永丰路交叉口西南角',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/c8fd0a18befbe849ce8df7908d88ed24',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/468baaf5453e6c1b38d0c4c417183b40',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/a0a5fff0b63e60b3508c2ecb197d07e5',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;娱乐场所;夜总会',\n",
       "     'shopinfo': '0',\n",
       "     'name': '一代佳人夜总会',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080000',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFKPS8TZ',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.471344,39.273170',\n",
       "     'distance': '2864',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '垦丰大街与永丰路交叉口南50米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;体育休闲服务场所;体育休闲服务场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '新少年跆拳道馆',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080402',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B013B031EO',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.469256,39.278622',\n",
       "     'distance': '2989',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '曙光街23号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;度假疗养场所;疗养院',\n",
       "     'shopinfo': '0',\n",
       "     'name': '光荣院(曙光街)',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080500',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFHF91Y9',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.467429,39.273141',\n",
       "     'distance': '3196',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '垦丰大街8号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;休闲场所;休闲场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '曹妃甸区老干部活动中心',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080119',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFLDK6TP',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.466867,39.281969',\n",
       "     'distance': '3222',\n",
       "     'tel': '17736580504',\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '建设大街红赫世家东底商58号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/b59e23956de23e47401416a6b4808c0c',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;运动场馆;跆拳道场馆',\n",
       "     'shopinfo': '0',\n",
       "     'name': '泽仁跆拳道',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080000',\n",
       "     'adname': '滦南县',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFH9MB8R',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.527757,39.301926',\n",
       "     'distance': '3343',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '杨柏线北50米',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;体育休闲服务场所;体育休闲服务场所',\n",
       "     'shopinfo': '0',\n",
       "     'name': '陶乐宝儿童乐园',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080304',\n",
       "     'adname': '曹妃甸区',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFLOR4DN',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.466494,39.287701',\n",
       "     'distance': '3395',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': '青年城二期东底商24号',\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': [{'url': 'http://store.is.autonavi.com/showpic/29997dd7b0c66b1dc6f15a253918ccf2',\n",
       "       'title': {},\n",
       "       'provider': {}},\n",
       "      {'url': 'http://store.is.autonavi.com/showpic/098df33a76f03e8d55672683f63da5d8',\n",
       "       'title': {},\n",
       "       'provider': {}}],\n",
       "     'type': '体育休闲服务;娱乐场所;酒吧',\n",
       "     'shopinfo': '1',\n",
       "     'name': 'ELK酒吧',\n",
       "     'childtype': {}},\n",
       "    {'typecode': '080113',\n",
       "     'adname': '滦南县',\n",
       "     'biz_type': {},\n",
       "     'id': 'B0FFMB6BAG',\n",
       "     'pname': '河北省',\n",
       "     'importance': {},\n",
       "     'parent': {},\n",
       "     'location': '118.528670,39.302678',\n",
       "     'distance': '3457',\n",
       "     'tel': {},\n",
       "     'biz_ext': {'rating': {}, 'cost': {}},\n",
       "     'shopid': {},\n",
       "     'address': {},\n",
       "     'poiweight': {},\n",
       "     'cityname': '唐山市',\n",
       "     'photos': {},\n",
       "     'type': '体育休闲服务;运动场馆;台球厅',\n",
       "     'shopinfo': '0',\n",
       "     'name': '下午时光台球俱乐部',\n",
       "     'childtype': {}}],\n",
       "   'infocode': '10000'},\n",
       "  'header': {'gsid': '011137149035158758280117300018601532358',\n",
       "   'Vary': 'Accept-Encoding',\n",
       "   'Content-Type': 'application/json;charset=UTF-8',\n",
       "   'Access-Control-Allow-Methods': '*',\n",
       "   'Access-Control-Allow-Origin': '*',\n",
       "   'sc': '0.113',\n",
       "   'Content-Length': 5564,\n",
       "   'Access-Control-Allow-Headers': 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,key,x-biz,x-info,platinfo,encr,enginever,gzipped,poiid',\n",
       "   'X-Powered-By': 'ring/1.0.0'}}]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def batch(url='/v3/place/around?offset=10&page=1&key=d9d5fa5d72ce3bcf4a2fee373f2e81af&location=118.50394379585519,39.278209477408794&output=json&radius=100000&types=080000'):\n",
    "    parameters = {\n",
    "            \"key\":key,\n",
    "        }\n",
    "    body ={\n",
    "        \"ops\": [\n",
    "            {\n",
    "                \"url\": '{}'.format(url)\n",
    "            },\n",
    "            {\n",
    "                \"url\": \"/v3/place/around?offset=10&page=1&key=d9d5fa5d72ce3bcf4a2fee373f2e81af&location=118.50394379585519,39.278209477408794&output=json&radius=100000&types=080000\"\n",
    "            }\n",
    "        ]\n",
    "    }\n",
    "    r=requests.get(\"https://restapi.amap.com/v3/batch?\", params=parameters,json=body)\n",
    "    data = r.json()\n",
    "    return data\n",
    "\n",
    "batch()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 静态地图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 可视化？展示地图的一部分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [],
   "source": [
    "def map(location:str,zoom:str):\n",
    "    \"\"\"zoom：设置地图大小\n",
    "       location：选择地图中心坐标\n",
    "    \"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'location':location,\n",
    "        'zoom':zoom,\n",
    "        \n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/staticmap?parameters\", params=parameters)\n",
    "    data = r.url\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'https://restapi.amap.com/v3/staticmap?parameters&key=0bb20430af3ae6336d0e9f0f21c10c1a&location=113.679287%2C23.632575&zoom=18'"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map(geo(\"广东省广州市从化区中山大学南方学院\",\"广州\"),18)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'https://restapi.amap.com/v3/staticmap?parameters&key=0bb20430af3ae6336d0e9f0f21c10c1a&location=113.632401%2C23.616941&zoom=18'"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map(geo(\"广东省广州市从化区温泉镇政府\",\"广州\"),18)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 坐标转换"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 人工智能分析坐标位置，转化合成需要的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "def assistant(locations:str,coordsys:str):\n",
    "    \"\"\"坐标转换\n",
    "    locations填入非高德坐标\n",
    "    coordsys可选值：gps,mapbar,baidu,autonavi（不进行转换）\n",
    "    \"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'coordsys':coordsys,\n",
    "        'locations':locations,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/assistant/coordinate/convert?parameters\", params=parameters)\n",
    "    data = r.json()['locations']\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'116.487585177952,39.991754014757;116.487585177952,39.991653917101'"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "assistant(\"116.481499,39.990475|116.481499,39.990375\",'gps')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 天气查询"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 在我看来天气查询本就是算法的一部分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "def weather(city:str):\n",
    "    \"\"\"天气查询\n",
    "    查询当地天气情况\"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'city':city,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/weather/weatherInfo?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    \"\"\"weather = []\n",
    "    weather.extend(data['weather'])\n",
    "    import pandas as pd\n",
    "    df_wea = pd.DataFrame(weather)\"\"\"\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'lives': [{'province': '广东',\n",
       "   'city': '深圳市',\n",
       "   'adcode': '440300',\n",
       "   'weather': '阴',\n",
       "   'temperature': '19',\n",
       "   'winddirection': '东',\n",
       "   'windpower': '≤3',\n",
       "   'humidity': '94',\n",
       "   'reporttime': '2020-04-23 03:22:35'}]}"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "weather('深圳')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 输入提示"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 可以用以语音输入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "def inputtips(keywords:str):\n",
    "    \"\"\"填写关键词课查询\"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/assistant/inputtips?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '10',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'tips': [{'id': 'B00140MR9A',\n",
       "   'name': '中山大学南方学院',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.679262,23.632583',\n",
       "   'address': '温泉大道882号',\n",
       "   'typecode': '141201',\n",
       "   'city': []},\n",
       "  {'id': 'B00141JCWL',\n",
       "   'name': '中山大学南方学院(西北门)',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.672109,23.643371',\n",
       "   'address': '温泉大道882',\n",
       "   'typecode': '991400',\n",
       "   'city': []},\n",
       "  {'id': 'B00141TRVH',\n",
       "   'name': '中山大学南方学院教学楼2号',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.677060,23.631346',\n",
       "   'address': '博学路21',\n",
       "   'typecode': '140000',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFF4TMDF',\n",
       "   'name': '中山大学南方学院体育馆',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.681360,23.633668',\n",
       "   'address': '温泉大道886号中山大学南方学院内',\n",
       "   'typecode': '080101',\n",
       "   'city': []},\n",
       "  {'id': 'B00141TR76',\n",
       "   'name': '中山大学南方学院教学楼4号',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.677460,23.630490',\n",
       "   'address': '博学路29',\n",
       "   'typecode': '140000',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFF2VMJ4',\n",
       "   'name': '中山大学南方学院-综合楼',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.680117,23.631544',\n",
       "   'address': '温泉大道886号中山大学南方学院内',\n",
       "   'typecode': '141200',\n",
       "   'city': []},\n",
       "  {'id': 'B00141TQGR',\n",
       "   'name': '中山大学南方学院教学楼7号',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.678600,23.633330',\n",
       "   'address': '博学路7',\n",
       "   'typecode': '141201',\n",
       "   'city': []},\n",
       "  {'id': 'B00141WQCO',\n",
       "   'name': '中山大学南方学院教学楼8号',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.680399,23.634329',\n",
       "   'address': '博学路附近',\n",
       "   'typecode': '140000',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFGB9V54',\n",
       "   'name': '中山大学南方学院停车场',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.676576,23.633195',\n",
       "   'address': '温泉大道886号中山大学南方学院内',\n",
       "   'typecode': '150905',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFLA81YC',\n",
       "   'name': '中山大学南方学院附属小学',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.522758,23.473157',\n",
       "   'address': '神岗镇',\n",
       "   'typecode': '141203',\n",
       "   'city': []}]}"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inputtips(\"中山大学南方学院\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 交通势态"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 计算机视觉、语音识别、推荐算法都可以使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "def rectangle(rectangle:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'rectangle':rectangle,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/traffic/status/rectangle?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'trafficinfo': {'description': '北三环路：双向畅通。',\n",
       "  'evaluation': {'expedite': '100.00%',\n",
       "   'congested': '0.00%',\n",
       "   'blocked': '0.00%',\n",
       "   'unknown': '0.00%',\n",
       "   'status': '1',\n",
       "   'description': '整体畅通'}}}"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rectangle(\"116.351147,39.966309;116.357134,39.968727\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 地理围栏"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：**  计算机视觉和推荐算法，做不出来。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [],
   "source": [
    "def create(name=\"测试围栏名称\",center=\"115.672126,38.817129\",radius= \"1000\",\n",
    "           valid_time=\"2020-05-19\",desc= \"测试围栏描述\"):\n",
    "    \"\"\"create创建一个地理围栏\"\"\"\n",
    "    parameters = {\n",
    "        \"key\":key,\n",
    "    }\n",
    "    body ={ \n",
    "        \"name\": name,\n",
    "        \"center\": center,\n",
    "        \"radius\": \"1000\",\n",
    "        \"enable\": \"true\",\n",
    "        \"valid_time\": \"2020-05-19\",\n",
    "        \"repeat\": \"Mon,Tues,Wed,Thur,Fri,Sat,Sun\",\n",
    "        \"time\": \"00:00,11:59;13:00,20:59\",\n",
    "        \"desc\": \"测试围栏描述\",\n",
    "        \"alert_condition\": \"enter;leave\"}\n",
    "    r = requests.post(\"https://restapi.amap.com/v4/geofence/meta\", params=parameters,json=body)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data': {'message': '新增围栏已存在', 'status': '106'},\n",
       " 'errcode': 0,\n",
       " 'errdetail': None,\n",
       " 'errmsg': 'OK',\n",
       " 'ext': None}"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "create(name=\"测试围栏名称2\",center=geo(\"中山大学\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 轨迹纠偏"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**ML、AI的功能：** 轨迹纠偏，算法自动推荐正确轨迹"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "def driving():\n",
    "    parameters = {\n",
    "            \"key\":key,\n",
    "        }\n",
    "    body =[\n",
    "        {\n",
    "            \"x\": 116.449429,\n",
    "            \"y\": 40.014844,\n",
    "            \"sp\": 4,\n",
    "            \"ag\": 110,\n",
    "            \"tm\": 1478831753},\n",
    "        {\n",
    "            \"x\": 116.449639,\n",
    "            \"y\": 40.014776,\n",
    "            \"sp\": 3,\n",
    "            \"ag\": 110,\n",
    "            \"tm\": 23}, \n",
    "        {\n",
    "            \"x\": 116.449859,\n",
    "            \"y\": 40.014716,\n",
    "            \"sp\": 3,\n",
    "            \"ag\": 111,\n",
    "            \"tm\": 33}, \n",
    "        {\n",
    "            \"x\": 116.450074,\n",
    "            \"y\": 40.014658,\n",
    "            \"sp\": 3,\n",
    "            \"ag\": 110,\n",
    "            \"tm\": 31}, \n",
    "        {\n",
    "            \"x\": 116.450273,\n",
    "            \"y\": 40.014598,\n",
    "            \"sp\": 3,\n",
    "            \"ag\": 111,\n",
    "            \"tm\": 20}]\n",
    "    r=requests.get(\"https://restapi.amap.com/v4/grasproad/driving\", params=parameters,json=body)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data': {'distance': 33.0,\n",
       "  'points': [{'x': 116.44942000249563, 'y': 40.014843356125866},\n",
       "   {'x': 116.44945705955585, 'y': 40.01453960973057}]},\n",
       " 'errcode': 0,\n",
       " 'errdetail': None,\n",
       " 'errmsg': 'OK',\n",
       " 'ext': None}"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "driving()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 简单应用"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 互联网冲浪天气宝\n",
    "首先**获取IP地址**进行定位，同时可以**获取地理编码**，进行**行政区域查询**从而直接向用户输出**天气信息**。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "384px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
